/*
 * @lc app=leetcode.cn id=746 lang=javascript
 *
 * [746] 使用最小花费爬楼梯
 */

// @lc code=start
/**
 * @param {number[]} cost
 * @return {number}
 */
var minCostClimbingStairs = function(cost) {

  let minCost = [];
  minCost[0] = 0;
  minCost[1] = Math.min(cost[0], cost[1]);
  for (let i = 2; i < cost.length; i++) { 
    minCost[i] = Math.min(minCost[i-1]+cost[i],minCost[i-2]+cost[i-1])

  }
  return minCost[cost.length-1]

};
// console.log(minCostClimbingStairs([1,100,1,1,1,100,1,1,100,1]));
// @lc code=end

